﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类P_DDTYPE。
	/// </summary>
	[Serializable]
	public partial class P_DDTYPE
	{
		public P_DDTYPE()
		{}
		#region Model
		private string _ddtype;
		private string _ddname;
		/// <summary>
		/// 
		/// </summary>
		public string DDTYPE
		{
			set{ _ddtype=value;}
			get{return _ddtype;}
		}
		/// <summary>
		/// 
		/// </summary>
		public string DDNAME
		{
			set{ _ddname=value;}
			get{return _ddname;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public P_DDTYPE(string DDTYPE)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select DDTYPE,DDNAME ");
			strSql.Append(" FROM P_DDTYPE ");
			strSql.Append(" where DDTYPE=:DDTYPE ");
			OracleParameter[] parameters = {
					new OracleParameter(":DDTYPE", OracleType.VarChar,50)};
			parameters[0].Value = DDTYPE;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["DDTYPE"]!=null && ds.Tables[0].Rows[0]["DDTYPE"].ToString()!="")
				{
					this.DDTYPE=ds.Tables[0].Rows[0]["DDTYPE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DDNAME"]!=null && ds.Tables[0].Rows[0]["DDNAME"].ToString()!="")
				{
					this.DDNAME=ds.Tables[0].Rows[0]["DDNAME"].ToString();
				}
			}
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string DDTYPE)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from P_DDTYPE");
			strSql.Append(" where DDTYPE=:DDTYPE ");

			OracleParameter[] parameters = {
					new OracleParameter(":DDTYPE", OracleType.VarChar,50)};
			parameters[0].Value = DDTYPE;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into P_DDTYPE (");
			strSql.Append("DDTYPE,DDNAME)");
			strSql.Append(" values (");
			strSql.Append(":DDTYPE,:DDNAME)");
			OracleParameter[] parameters = {
					new OracleParameter(":DDTYPE", OracleType.VarChar,40),
					new OracleParameter(":DDNAME", OracleType.VarChar,20)};
			parameters[0].Value = DDTYPE;
			parameters[1].Value = DDNAME;

			DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update P_DDTYPE set ");
			strSql.Append("DDNAME=:DDNAME");
			strSql.Append(" where DDTYPE=:DDTYPE ");
			OracleParameter[] parameters = {
					new OracleParameter(":DDNAME", OracleType.VarChar,20),
					new OracleParameter(":DDTYPE", OracleType.VarChar,40)};
			parameters[0].Value = DDNAME;
			parameters[1].Value = DDTYPE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string DDTYPE)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from P_DDTYPE ");
			strSql.Append(" where DDTYPE=:DDTYPE ");
			OracleParameter[] parameters = {
					new OracleParameter(":DDTYPE", OracleType.VarChar,50)};
			parameters[0].Value = DDTYPE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(string DDTYPE)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select DDTYPE,DDNAME ");
			strSql.Append(" FROM P_DDTYPE ");
			strSql.Append(" where DDTYPE=:DDTYPE ");
			OracleParameter[] parameters = {
					new OracleParameter(":DDTYPE", OracleType.VarChar,50)};
			parameters[0].Value = DDTYPE;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["DDTYPE"]!=null && ds.Tables[0].Rows[0]["DDTYPE"].ToString()!="")
				{
					this.DDTYPE=ds.Tables[0].Rows[0]["DDTYPE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DDNAME"]!=null && ds.Tables[0].Rows[0]["DDNAME"].ToString()!="")
				{
					this.DDNAME=ds.Tables[0].Rows[0]["DDNAME"].ToString();
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM P_DDTYPE ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

